package com.tte.common.java8;

import com.tte.common.mapper.UserMapper;
import com.tte.common.model.po.User;

import java.util.Date;
import java.util.concurrent.Callable;

/**
 * Lambda测试类
 */
public class LambdaTest {

    private static UserMapper userMapper;

    public static void main(String[] args) throws Exception {
        String id  = "1";
        User a = getUser(() -> get(id));
        System.out.println(a);

        System.out.println("-----------****************---------------");
        System.out.println(get(id));
        System.out.println("-----------****************---------------");

        Callable<User> callable = () -> get(id);//Runnable
        System.out.println(callable.call());

    }

    private static <T> T getUser(Callable<T> collable) throws Exception {
        return collable.call();
    }

    private static User get(String id){
        return new User("user001", "admin", "管理员", 0, new Date());
    }
}
